parser grammar XMLParser;

options {
  language = Java;
  tokenVocab = XMLLexer;
}

@header {
package PL.prac8;
} 

entrada returns [boolean igual = true]: a=elemento{if(!a) igual = false;} EOF;
elementos: (elemento)*;
elemento returns [boolean igual = true]: a=apertura elementos b=cierre  {if (!a.equals(b)){ igual = false;
                                                                         System.out.println("Apertura: "+a+" y cierre: "+ b+ " no corresponden");}} 
                                       | PALABRA|CADENA;
apertura returns [String salida = ""]: MENOR a=PALABRA MAYOR {salida = a.getText();};
cierre returns [String salida = ""]: MENOR BARRA a=PALABRA MAYOR {salida = a.getText();};